#include "comm.hpp"

int main()
{
    //创建mmap映射
    Mmap mp(MMAP_FILE, 4096);

    //使用命名管道
    FIFO fifo;
    int fd = FIFO::open_read(FIFO_FILE);

    //进程通信代码
    char* str = (char*)mp.get();
    while (true)
    {
        char sign = 0;
        int n = read(fd, &sign, sizeof(sign));
        if (n == sizeof(sign))
            std::cout << "client sent: " << str << std::endl;
        else if (n == 0)
        {
            std::cout << "client exit" << std::endl;
            sleep(2);
            break;
        }
        sleep(1);
    }
    close(fd);

    return 0;
}
